﻿// 功能：马达震动API
// 描述：
// 作者：温伟鹏
// 日期：2010/5/12 11:14:48

using System;
using System.Runtime.InteropServices;

namespace MeizuSDK.Core
{
    /// <summary>
    /// 马达震动API
    /// </summary>
    public sealed class MotorVibrateAPI
    {
        /// <summary>
        /// 关闭马达震动 
        /// </summary>
        [DllImport("PlatformAPIWrapper.dll", SetLastError = true, EntryPoint = "SetVibrateOff")]
        private static extern void MzSetVibrateOff();
        /// <summary>
        /// 关闭马达震动
        /// </summary>
        public static bool SetVibrateOff()
        {
            try
            {
                MzSetVibrateOff();

                return true;
            }
            catch
            {
                return false;
            }
        }
        /// <summary>
        /// 开启马达震动。调整onTime与offTime来设置马达的通断时间
        /// </summary>
        /// <param name="onTime">马达震动时间</param>
        /// <param name="offTime">马达停震时间</param>
        [DllImport("PlatformAPIWrapper.dll", SetLastError = true, EntryPoint = "SetVibrateOn")]
        private static extern void MzSetVibrateOn(int onTime, int offTime);
        /// <summary>
        /// 开启马达震动。调整onTime与offTime来设置马达的通断时间
        /// </summary>
        /// <param name="onTime">马达震动时间</param>
        /// <param name="offTime">马达停震时间</param>
        public static bool SetVibrateOn(int onTime, int offTime)
        {
            try
            {
                MzSetVibrateOn(onTime, offTime);
                return true;
            }
            catch
            {
                return false;
            }
        }
    }
}
